/*
============================================================================
 Name        : PluginUtility.cpp
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : CPluginUtility implementation
============================================================================
*/

#include "PluginUtility.h"

#include <f32file.h>	//TFilename, TParsePtr
#include <fbs.h>		//CFbsBitmap
#include <eikenv.h>		//CEikonEnv
#include <eikapp.h>     // CEikApplication
#include <aknappui.h>   // CAknAppUi


#include <http.h>			//RHTTPSession
#include <stringpool.h>		//RStringF

EXPORT_C void CPluginUtility::AddMenuItem(TInt aCommandId, TPtrC aText, CEikMenuPane* aMenuPane, TBool aDimmed)
{
	CEikMenuPaneItem::SData sd;
	sd.iCommandId = aCommandId;
	sd.iText.Copy(aText);
	sd.iFlags = 0;
	sd.iCascadeId = 0;
	TRAPD(err, aMenuPane->AddMenuItemL(sd));
	aMenuPane->SetItemDimmed(aCommandId, aDimmed);
}

EXPORT_C CFbsBitmap* CPluginUtility::CreateBitmapL(const TDesC& aMbmFileName, TInt aBitmapKey)
{
	//Create background bitmap
    TFileName fileName;
    fileName.Copy(CEikonEnv::Static()->EikAppUi()->Application()->AppFullName());
    TParsePtr parse(fileName);

	fileName.Copy(parse.DriveAndPath());
    fileName.Append(aMbmFileName);
    
	return CEikonEnv::Static()->CreateBitmapL(fileName, aBitmapKey);
}
